<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Stimulus360.Controllers.Projects.ProjectDocumentsViewModel>" %>

<%@ Import Namespace="Stimulus360.Models.Cms" %>
<%@ Import Namespace="Stimulus360.Models.Data.CustomTypes" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="Stimulus360.Services" %>
<%@ Import Namespace="Stimulus360.Controllers" %>
<%@ Import Namespace="Stimulus360.Models.Data" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <% ProjectSummary project = Model.ProjectSummary;

       RatingViewModel ratingViewModel = new RatingViewModel
       {
           Id = project.ProjectId,
           AverageRating = project.AverageRating,
           IsDisabled = true,
           IdeaId = project.ProjectId
       };

       PaginatedCollection<ProjectDocument> docList = Model.Documents;
    %>
    <div class="centerContainer">
        <%Html.RenderPartial("ProjectDetailLeftNavigation", project); %>
        <div class="mainInner colViewHdr">
            <div>
            <div class="projListItem floatLeft p10">
                <h1><%=Html.Encode(Model.ProjectSummary.ProjectTitle) %></h1>
                <div class="projStatusBar mt10">
                    <div class="floatLeft pt02">
                        <%=Model.ProjectSummary.SubmittedDate.ToString("D", CultureInfo.CreateSpecificCulture("en-US"))%>
                        | PM: <%=Model.ProjectSummary.Submitter %></div>
                    <div class="projStatus floatLeft pl10">
                        <div>
                            <%Html.RenderPartial("Rating", ratingViewModel); %></div>
                        <div class="separatorR">
                            (<%=Model.ProjectSummary.UserRatingsCount %>)</div>
                        <div class="separatorR pt02">
                            Favorites
                            <%=Model.ProjectSummary.FavoritesCount%></div>
                        <div class="projStatusRpt">
                            <h4>
                                Status:
                            </h4>
                            <div>
                                &nbsp;<%= Html.Image(Model.ProjectSummary.StatusString.ToLower() + ".png", Model.ProjectSummary.StatusString)%>
                            </div>
                            <div class="statusWdth"><%=Model.ProjectSummary.StatusString %></div>
                        </div>
                        <br clear="all" />
                    </div>
                </div>
            </div>
            <div class="floatRight mr10 pt10">
                <a href="/Projects/<%=project.ProjectId%>/Documents/Submit" class="headerLabelBtn"><span>
                    Submit Document</span></a>
            </div>
            <br clear="all" />
            </div>
            <h3>Documents</h3>
            <%foreach (ProjectDocument document in docList)
              { %>
                <div class="projListDocItem projListItemBg <%=Enum.Parse(typeof(DocType), document.DocumentType.ToString()) %>">            
                <h1>&nbsp; <a id="<%=document.DocumentId %>" href="/Projects/<%=document.ProjectId %>/Documents/<%=document.DocumentId %>" target="_parent">
                        <%=Html.Encode(document.Title) %>
                    </a>
                </h1>
                <br />
                <div class="pl25">
                    <%=document.DateUploaded.ToString("D", CultureInfo.CreateSpecificCulture("en-US"))%>
                    | by <%=document.SubmittedBy%></div>
            </div>
            <%} %>
            <br clear="all" />
        </div>
        <br clear="all" />
        <br />
        <div class="pagerbg">
            <div id="pagerDocList" class="pager">
            </div>
        </div>
        <br clear="all" />
    </div>

    <script type="text/javascript" language="javascript">
      $(document).ready(function() {
      $("#documentsTag").addClass("selected");
          var totalPages_Idea = "<%=Model.Documents.TotalPages %>";
          if (totalPages_Idea <= 1) {
              $(".pagerbg").hide();
          }
          var currentPage = "<%=Model.Documents.PageIndex%>";
          $("#pagerDocList").pager({ pagenumber: currentPage, pagecount: totalPages_Idea, buttonClickCallback: PageClick_IdeaList });
      });
      PageClick_IdeaList = function(pageclickednuber) {
          var proj = "<%=Model.ProjectSummary.ProjectId%>";
          var pageIndex = pageclickednuber;
          window.location = "/Projects/" + proj.toString() + "/Documents/Page/" + pageIndex.toString();
      }
      
    </script>

</asp:Content>
